﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LiuYan.Service;
using LiuYan.Web.Areas.Admin.print;
using Newtonsoft.Json;

namespace LiuYan.Web.Areas.Admin.Controllers
{
    public class ShouyinController : BaseController
    {
        //
        // GET: /Admin/Shouyin/

        public ActionResult Index()
        {
        // new PrintService1().Printeg();
            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            ViewData["orderno"]=Convert.ToInt64(ts.TotalSeconds).ToString();
            ViewData["sort"] = new SortService().GetList();
            return View();

        }

        public string GetPro(int sid)
        {
            return JsonConvert.SerializeObject(new GoodService().GetList(1000,0,"",sid).Tables[1]);
        }

        public int Addorder(double money, int userid, string spids, string count, string prices,
            string discount, string orderno, double sjmoney, double hyye)
        {
            var row= new OrderService().AddOrder(money, userid, spids, count, prices, discount, orderno, sjmoney, hyye);
            if (row > 0)
            {
                try
                {
                    new PrintService1().Printeg(orderno, money, sjmoney, hyye, userid);
                }
                catch (Exception e)
                {
                    return -2;
                }
              
            }
            return row;
            
        }
    }
}
